import pymysql
from django.shortcuts import render

#Create your view here
from django.http import HttpResponse
from django.shortcuts import render
from config import config

def connect_database():
    host,user,password,db = config.mysql_info()
    db = pymysql.connect(host=host, user=user, password=password, db=db)
    cursor = db.cursor()
    return cursor



def index(request):
    username = request.POST.get('username')
    password = request.POST.get('password')
    print(username)
    print(password)
    return render(request,'index.html')


def register(request):
    username = request.POST.get('username')
    password = request.POST.get('password')
    email = request.POST.get('email')
    confirm_password = request.POST.get('confirm_password')
    sql = "insert into users values ('"+username+"','"+email+"','"+password+"','"+confirm_password+"')"
    cursor = connect_database()
    cursor.execute(sql)
    print(username,password,email,confirm_password)
    return render(request,'register.html')














































